//
//  UIBarButtonItem+EPM.m
//  WeiBoByOC
//
//  Created by 马继鵬 on 17/3/20.
//  Copyright © 2017年 7TH. All rights reserved.
//

#import "UIBarButtonItem+EPM.h"

@implementation UIBarButtonItem (EPM)
+ (instancetype)EPM_Title:(NSString*)title imageName:(NSString*)imageName target:(id) target action:(SEL)selector
{
    UIButton* btn = [[UIButton alloc]init];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",imageName]] forState:UIControlStateHighlighted];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:14];
    [btn sizeToFit];
    //添加点击事件
    [btn addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* bar = [self new];
    bar.customView = btn;
    return bar;
}

+ (instancetype)EPM_imageName:(NSString *)imageName target:(id)target action:(SEL)selector
{
    return  [self EPM_Title:nil imageName:imageName target:target action:selector];
}

@end
